<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Словарик для хранения *скалярных* величин "без повторов"
 *
 * @author chaporgin_a
 */
class VA_Form_Dictionary {
    private $dictionary = array();
    public function Set($name, $value, $removeOthers = FALSE){
      if($removeOthers || (!key_exists($name, $this->dictionary))){
        $this->dictionary[$name] = array($value);
        return $this;
      }
      if( !in_array($value, $this->dictionary[$name]))
        $this->dictionary[$name][] = $value;
      return $this;
    }
    public function Get($name){
      if(key_exists($name, $this->dictionary))
        return $this->dictionary[$name];
      return null;
    }
    public function GetAll(){
      return $this->dictionary;
    }
    public function GetNames(){
      return array_keys($this->dictionary);
    }
}

